package service.appversion;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pojo.AppVersion;

import dao.appinfo.AppInfoMapper;
import dao.appversion.AppVersionMapper;

@Service
public class appversionServiceImpl implements appversionService{
@Autowired
private AppVersionMapper appVersionMapper;
@Autowired
private AppInfoMapper appInfoMapper;
	@Override
	public int delVersion(Integer appId) {
		// TODO Auto-generated method stub
		return appVersionMapper.delVersion(appId);
	}
	@Override
	public List<AppVersion> getAppVersionList(Integer appId) {
		// TODO Auto-generated method stub
		return appVersionMapper.getAppVersionList(appId);
	}
	@Override
	public int add(AppVersion appVersion) {
		// TODO Auto-generated method stub
		int flag = -1;
		Integer versionId = null;
		if(appVersionMapper.add(appVersion) > 0){
			versionId = appVersion.getId();
			flag = 0;
		}
		if(appInfoMapper.updateVersionId(versionId, appVersion.getAppId()) > 0 && flag==0){
			flag = 1;
		}
		return flag;
	}
	@Override
	public int modify(AppVersion appVersion) {
		// TODO Auto-generated method stub
		return appVersionMapper.modify(appVersion);
	}
	@Override
	public AppVersion getAppVersionById(Integer id) {
		// TODO Auto-generated method stub
		return appVersionMapper.getAppVersionById(id);
	}


}
